<%@ page contentType="text/html;charset=UTF-8" %>
<%@page import="com.sks.bean.pojo.House"%>
<%@ include file="../share/taglib.jsp" %>
<%@ include file="../share/isReadOnly.inc" %>
<html>
<head>
<title>房源管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="/css/vip.css" type="text/css">
<script type="text/javascript" src="/js/jquery-1.3.1.min.js"></script>
<script language="JavaScript">
//到指定的分页页面
function topage(page){
	var form = document.forms[0];
	form.page.value=page;
	form.submit();
}
function deleteHouse(url) {
	if(!confirm('你确定要删除该房源吗？')) {
		return false;
	}
	window.location.href = url;
}
function queryHouse() {
	document.forms[0].query.value = 'true';
	document.forms[0].submit();	
}
function clearCondition() {
	document.forms[0].title.value = '';
	document.forms[0].houseStatus.value = '';
	document.forms[0].transaStatus.value = '';
	document.forms[0].isHot.value = '';
	document.forms[0].menuName.value = '';
	document.forms[0].minPrice.value = '';
	document.forms[0].maxPrice.value = '';
	document.forms[0].query.value = 'false';
	document.forms[0].submit();
}
function setHot(obj) {
	$.post("/cms/house.do", {method:"setHot", houseId:obj.value, isHot:obj.checked},
     function (data, textStatus){
	     if (!data.success) {
	    	 alert(data.msg);
	     }
     }, "json");
}
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000" marginwidth="0" marginheight="0">
<html:form action="/cms/house.do" method="post">
<html:hidden property="page"/>
<html:hidden property="query"/>
<html:hidden property="method" value="list"/>
  <table width="98%" border="0" cellspacing="1" cellpadding="2" align="center">
  	<tr bgcolor="f5f5f5"> 
      <td width="10%"><div align="right"><bean:message key="info.house.field.title"/>：</div></td>
      <td width="40%">
      	<html:text property="title" size="30"/>
      </td>
      
      <td width="15%"><div align="right">房源状态：</div></td>
	  <td colspan="3">
	    <html:select property="houseStatus">
	    	<html:option value="">-</html:option>
      		<html:option value="<%=House.HOUSE_STATUS_NONE_AUDIT%>"><bean:message key="info.house.status.noneAudit"/></html:option>
      		<html:option value="<%=House.HOUSE_STATUS_AUDITED%>"><bean:message key="info.house.status.audited"/></html:option>
      		<html:option value="<%=House.HOUSE_STATUS_PUBLISHED%>"><bean:message key="info.house.status.published"/></html:option>
      		<html:option value="<%=House.HOUSE_STATUS_FINISHED%>"><bean:message key="info.house.status.finished"/></html:option>
      		<html:option value="<%=House.HOUSE_STATUS_INVALIDATE%>"><bean:message key="info.house.status.invalidate"/></html:option>
      	</html:select>
	  </td>
    </tr>
    <tr bgcolor="f5f5f5"> 
      <td width="10%"><div align="right">交易类型：</div></td>
      <td width="40%">
      	<html:select property="transaStatus">
      		<html:option value="">-</html:option>
      		<html:option value="0"><bean:message key="info.house.transaction.status0"/></html:option>
      		<html:option value="1"><bean:message key="info.house.transaction.status1"/></html:option>
      		<html:option value="2"><bean:message key="info.house.transaction.status2"/></html:option>
      	</html:select>
      </td>
      
      <td width="15%"><div align="right">是否热点：</div></td>
	  <td colspan="3">
	    <html:select property="isHot">
      		<html:option value="">-</html:option>
      		<html:option value="true">是</html:option>
      		<html:option value="false">否</html:option>
      	</html:select>
	  </td>
    </tr>
    <tr bgcolor="f5f5f5"> 
      <td width="10%"><div align="right">价格类型：</div></td>
      <td width="40%" valign="middle">
      	<html:select property="menuName">
      		<html:option value="">-</html:option>
      		<html:option value="rentPrice">租赁</html:option>
      		<html:option value="salePrice">出售</html:option>
      	</html:select>
      </td>
      
      <td width="15%"><div align="right">价格范围：</div></td>
	  <td colspan="3">
	  	<html:text property="minPrice" size="12"/>&nbsp;-&nbsp;<html:text property="maxPrice" size="12"/>
	  </td>
    </tr>
    
    <tr> 
      <td bgcolor="f5f5f5" colspan="6" align="center"><table width="100%" border="0" cellspacing="1" cellpadding="3">
          <tr> 
            <td width="5%"></td>
            <td width="85%">
              <button type="button" onClick="javascript:queryHouse();">&nbsp;<bean:message key="display.query"/>&nbsp;</button>&nbsp;&nbsp;
              <button type="button" onClick="javascript:clearCondition();">清除查询条件</button>
            </td>
          </tr>
        </table></td>
    </tr>
  	
    <tr><td colspan="6" bgcolor="#ffbe26" align="right">
    	<%@ include file="../share/fenye.jsp" %>
	</td></tr>
    <tr>
      <td width="10%" bgcolor="#ffbe26"> <div align="center"><font color="#000000">代号</font></div></td>
      <td width="40%" bgcolor="#ffbe26"> <div align="center"><font color="#000000">房源标题</font></div></td>
      <td width="15%" bgcolor="#ffbe26"> <div align="center"><font color="#000000">交易类型</font></div></td>
      <td width="15%" bgcolor="#ffbe26"> <div align="center"><font color="#000000">房源状态</font></div></td>
      <td width="10%" bgcolor="#ffbe26"> <div align="center"><font color="#000000">热点推荐</font></div></td>
      <td width="10%" nowrap bgcolor="#ffbe26"> <div align="center"><font color="#000000">删除</font></div></td>
    </tr>
<!---------------------------LOOP START------------------------------>
<c:forEach items="${pageView.records}" var="entry">
    <tr>
      <td bgcolor="f5f5f5"><div align="center">${entry.houseId}</div></td>
      <td bgcolor="f5f5f5"><div align="center"><a href="<html:rewrite action="/cms/house"/>?method=editUI&houseId=${entry.houseId}&type=Base">${entry.title}</a></div></td>
      <td bgcolor="f5f5f5"><div align="center"><bean:message key="info.house.transaction.status${entry.transaStatus}"/></div></td>
      <td bgcolor="f5f5f5"><div align="center"><bean:message key="info.house.status.${entry.houseStatus}"/></div></td>
      <td bgcolor="f5f5f5"><div align="center">
      
      <input type="checkbox" value="${entry.houseId}" onclick="setHot(this);" ${entry.isHot ? "checked='checked'" : ''} <%=isReadOnly?"disabled='disabled'":""%>/>
      </div></td>
	  <td bgcolor="f5f5f5"><div align="center">
	  <% if (isReadOnly) { %>
	  -
	  <% } else { %>
	  <c:if test="${entry.houseStatus eq 'noneAudit'}">
	  <img src="/images/delete.gif" width="15" height="16" border="0" onclick="javascript:deleteHouse('/cms/house.do?method=delete&houseId=${entry.houseId}');" style="cursor:hand;">
	  </c:if>
	  <c:if test="${entry.houseStatus ne 'noneAudit'}">
	  -
	  </c:if>
	  <% } %>
	  </div>
	  </td>
	</tr>
</c:forEach>
    <!----------------------LOOP END------------------------------->
    <tr> 
      <td bgcolor="f5f5f5" colspan="6" align="center"><table width="100%" border="0" cellspacing="1" cellpadding="3">
          <tr> 
            <td width="5%"></td>
              <td width="85%">
              <input name="AddDic" <%=isReadOnly ? "disabled='disabled'" : ""%> type="button"
              class="frm_btn" id="AddDic" onClick="javascript:window.location.href='<html:rewrite action="/cms/house"/>?method=addUI'" value="添加房源"> &nbsp;&nbsp;
            </td>
          </tr>
        </table></td>
    </tr>
  </table>
</html:form>
</body>
</html>